/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ResultEditor.AnnotationClasses;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JCheckBox;

/**
 *
 * @author leng 
 */
/**New java swing conponent extend from JCheckBox.*/
public class JClassCheckBox extends JCheckBox {
    protected Color c;
    protected int annotationAmount;
    protected int annotationTypeAmount;
    protected String classname;
    protected boolean isSelected_toCreateAnnotation = false;

    public JClassCheckBox(){
        super();
    }

    public void setflag_isSelected_toCreateAnnotation(boolean flag){
        isSelected_toCreateAnnotation = flag;
    }

    public boolean isSelected_toCreateAnnotation(){
        return isSelected_toCreateAnnotation;
    }

    public void setClassColor(Color c){
        this.c = c;
    }

    public Color getClassColor(){
        return c;
    }

    public void setAnnotationAmount( int amount ){
        this.annotationAmount = amount;
    }

    public int getAnnotationAmount(){
        return this.annotationAmount;
    }

    public void setAnnotationTypeAmount( int amount ){
        this.annotationTypeAmount = amount;
    }

    public int getAnnotationTypeAmount(){
        return this.annotationTypeAmount;
    }

    public void setClassname( String classname ){
        this.classname = classname.trim();
    }

    public String getClassname() {
        return this.classname;
    }

    @Override
    public void paint(Graphics g){
      super.paint( g );
      Graphics2D g2 = (Graphics2D) g;
      // g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

      // draw color block
      g2.setColor( new Color(150,150,150) );
      g2.drawRect( getX() + 10 , 2, 14, 14);
      // fill rect
      if (c == null)
        c = Color.CYAN;

      g2.setColor(c);
      g2.fillRect(getX() + 11 , 3, 13, 13);

      if( !isSelected_toCreateAnnotation )
          return;

      // set color of corss line, which indicates selected annotatin class
      Color crossLineColor = Color.black;
      if (( c.getRed() < 30 )&&( c.getBlue() < 10 )&&( c.getGreen() < 10 )) {
          crossLineColor = Color.white;
      }
      g2.setColor(crossLineColor);
      // draw cross line
      g2.drawLine(getX() + 11, 3, getX() + 10 + 13, 3+13);
      g2.drawLine(getX() + 11, 3+13, getX() + 10 + 13, 3);
      // draw text
      //setColor( Color.black );
      //setFont(new Font("Arial", Font.PLAIN, 11 ));
      //drawString("C", getX()+13, getHeight()/2 + 5 );

    }

}
